//
//  IntegralListView.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/12.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ResidenceIntegralListView.h"
#import "ResidenceIntegralCell.h"
#import "BaseTableView+EmptyData.h"

@interface ResidenceIntegralListView ()

@property (nonatomic, strong) UIView *headView;

@end

@implementation ResidenceIntegralListView



- (UIView *)headView {
  if(!_headView) {
    _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.yt_width, 44)];
    
    ///!
    UIImageView *listImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 15, 20)];
    listImageView.image = [UIImage imageNamed:@"Residence_Integrallist"];
    [_headView addSubview:listImageView];
    
    UILabel *countTitle = [[UILabel alloc] initWithFrame:CGRectMake(listImageView.yt_right+2, 0, 120, _headView.yt_height)];
    countTitle.textAlignment = NSTextAlignmentLeft;
    countTitle.textColor = DEF_BLACK;
    countTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:16.0f];
    countTitle.text = YTLocalizedString(@"积分记录");
    [_headView addSubview:countTitle];
    
    UIImageView *arrowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 15, 20, 20)];
    arrowImageView.yt_centerY = _headView.yt_height/2;
    arrowImageView.yt_right = self.yt_width - listImageView.yt_left;
    [_headView addSubview:arrowImageView];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(listImageView.yt_left, _headView.yt_height - 1, self.yt_width - listImageView.yt_left * 2, 1)];
    lineView.backgroundColor = DEF_GRAY;
    [_headView addSubview:lineView];
    
    
    
  }
  return _headView;
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
  self = [super initWithFrame:frame style:style];
  if (self) {
 
  }
  return self;
}

- (void)setup {
  
  self.layer.masksToBounds = YES;
  self.layer.cornerRadius = 8.0f;
  self.layer.borderWidth = 0.5;
  
  self.tableHeaderView = self.headView;
  [self hideTableFootView];
  
//  UIView *contenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.yt_width, self.yt_height)];
//  contenView.backgroundColor = [UIColor orangeColor];
//  self.backgroundView = contenView;
//  self.separatorStyle = UITableViewCellSeparatorStyleNone;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  [self tableViewDisplayWithMsg:YTLocalizedString(@"未有积分记录") imageName:@"empty_message" ifNecessaryForRowCount:self.data.count];
  return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *identify = @"listCell";
  
  ResidenceIntegralCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
  if (!cell) {
    cell = [[ResidenceIntegralCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
  }
  
  return cell;
  
  
}



@end
